<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create("system_config", function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->comment("参数名");
            $table->string('key')->unique()->comment("参数键");
            $table->string('value')->nullable()->comment("参数值");
            $table->text('remark')->nullable();
            $table->timestamps();
            $table->comment("系统配置表");
        });

        Schema::create("system_data", function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->comment("数据名");
            $table->string('key')->unique()->comment("数据键");
            $table->text('value')->nullable()->comment("数据内容");
            $table->string('remark')->nullable();
            $table->timestamps();
            $table->comment("系统数据表");
        });

        Schema::create("system_dict", function (Blueprint $table) {
            $table->increments('id');
            $table->string('dict_name')->comment("字典名");
            $table->string('dict_key')->unique()->comment("字典索引");
            $table->tinyInteger('state')->default(0)->comment('状态');
            $table->text('remark')->nullable()->comment("备注");
            $table->timestamps();
            $table->comment("系统字典");
        });

        Schema::create("system_dict_data", function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger("dict_id")->comment("字典表id");
            $table->string('dict_label')->comment("标签");
            $table->string('dict_value')->comment("值");
            $table->tinyInteger('sort')->default(0)->comment("排序");
            $table->tinyInteger('state')->default(0)->comment('状态');
            $table->tinyInteger('is_default')->default(0)->comment('是否默认值');
            $table->text('remark')->nullable()->comment("备注");
            $table->timestamps();
            $table->comment("系统字典数据");
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('system_config');
        Schema::dropIfExists('system_dict');
        Schema::dropIfExists('system_dict_data');
    }
};
